package com.xujl.task;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class TaskUtils {
    private static final SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss SSS");

    /**
     * 生成有边界的Int
     *
     * @param min
     * @param max
     * @return
     */
    public static int getRandomForIntegerBounded (int min, int max) {
        int intBounded = min + ((int) (new Random().nextFloat() * (max - min)));
        return intBounded;
    }

    /**
     * 时间戳转换成字符窜
     *
     * @return
     */
    public static String createTaskId () {
        Date date = new Date(System.currentTimeMillis());
        return format.format(date) + "-" + new Random().nextInt(10000);
    }
}
